//
//  DetailViewController.m
//  TY-C
//
//  Created by xyyl on 2024/3/4.
//

#import "DetailViewController.h"
#import "Detail_LineBtn.h"
@interface DetailViewController ()

///
@property (nonatomic,strong) Detail_LineBtn * lineBtn1;
@property (nonatomic,strong) Detail_LineBtn * lineBtn2;

///
@property (nonatomic,strong) UIView * view1;
///
@property (nonatomic,strong) UIView * view2;



@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.view.backgroundColor = [UIColor greenColor];
    
    [self initTopBtn];
    [self initViews];
    
}

- (void)initTopBtn {
    _lineBtn1 = [[Detail_LineBtn alloc]initWithFrame:CGRectMake(25*IPADSCALE, 18*IPADSCALE, 70*IPADSCALE, 21*IPADSCALE)];
    _lineBtn1.selected = YES;
    _lineBtn1.nameLab.text = @"关于本机";
    [self.view addSubview:_lineBtn1];
    
    _lineBtn2 = [[Detail_LineBtn alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_lineBtn1.frame), CGRectGetMinY(_lineBtn1.frame), 70*IPADSCALE, 21*IPADSCALE)];
    _lineBtn2.selected = NO;
    _lineBtn2.nameLab.text = @"产品详情";
    [self.view addSubview:_lineBtn2];

    [_lineBtn1 addTarget:self action:@selector(lineBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [_lineBtn2 addTarget:self action:@selector(lineBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

- (void)lineBtnAction:(UIButton *)btn {
    _lineBtn1.selected = NO;
    _lineBtn2.selected = NO;
    btn.selected = YES;
    if(_view1) {
        if(btn == _lineBtn1){
            _view1.hidden = NO;
            _view2.hidden = YES;
        }else{
            _view1.hidden = YES;
            _view2.hidden = NO;
        }
    }
}

- (void)initViews {
    _view1 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_lineBtn1.frame), self.view.frame.size.width, ZYQHEIGHT - CGRectGetMaxY(_lineBtn1.frame))];
    
    [self.view addSubview:_view1];
    _view2 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_lineBtn1.frame), self.view.frame.size.width, ZYQHEIGHT - CGRectGetMaxY(_lineBtn1.frame))];
    [self.view addSubview:_view2];
    _view2.hidden = YES;
    
    
    
    NSArray * nameArray = @[@"设备名称",@"设备型号",@"硬件版本",@"软件版本"];
    NSArray * detArray = @[@"吞咽神经和肌肉电刺激仪",@"XY-K-TY-I",@"V 1.0.1",@"V 1.0.1"];

    
    for (int i = 0; i <nameArray.count; i++) {
        
        UILabel * ll = [UILabel new];
        ll.frame = CGRectMake(40*IPADSCALE, 43 * IPADSCALE + (22+15) * IPADSCALE * i, 40*IPADSCALE, 15*IPADSCALE);
        ll.text = nameArray[i];
        ll.textColor = RGBColor(102, 102, 102);
        ll.font = ZYQFONT(15);
        [_view1 addSubview:ll];
        
        
        UILabel * xx = [UILabel new];
        xx.frame = CGRectMake(CGRectGetMaxX(ll.frame) + (36*IPADSCALE), CGRectGetMinY(ll.frame), 150*IPADSCALE, CGRectGetHeight(ll.frame));
        xx.text = detArray[i];
        xx.textColor = RGBColor(51, 51, 51);
        xx.font = [UIFont boldSystemFontOfSize:15];
        [_view1 addSubview:xx];
        
    }
    
    
    
    if(_view2) {
        UILabel * ll2 = [UILabel new];
        [_view2 addSubview:ll2];
        
        ll2.text = @"一、工作原理";
        ll2.textColor = RGBColor(50, 60, 71);
        ll2.font = ZYQFONT(17);
        [ll2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view).offset(40*IPADSCALE);
            make.height.equalTo(@(16*IPADSCALE));
            make.top.equalTo(_lineBtn1.mas_bottom).offset(43*IPADSCALE);
        }];
        
        
        UILabel * ll3 = [UILabel new];
        [_view2 addSubview:ll3];
        ll3.text = @"吞咽神经和肌肉电刺激仪是我公司生产的一种医疗刺激仪，主要用于对吞咽非机械原因损伤引起的吞咽及构音障碍进行训练。刺激仪具有无创、方便、安全等优点是吞咽治疗科、语言治疗科、康复科、理疗科、神经科、消化科、儿科等常备的医疗刺激仪。";
        ll3.textColor = RGBColor(102, 102, 102);
        ll3.font = ZYQFONT(15);
        [ll3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(ll2);
            make.top.equalTo(ll2.mas_bottom).offset(5*IPADSCALE);
            make.right.equalTo(self.view.mas_right).offset(-40*IPADSCALE);
        }];
        ll3.numberOfLines = 0;
        
        
        UILabel * ll4 = [UILabel new];
        [_view2 addSubview:ll4];
        
        ll4.text = @"二、禁忌症";
        ll4.textColor = RGBColor(50, 60, 71);
        ll4.font = ZYQFONT(17);
        [ll4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.height.equalTo(ll2);
            make.top.equalTo(ll3.mas_bottom).offset(15*IPADSCALE);
            make.right.equalTo(self.view.mas_right).offset(-40*IPADSCALE);
        }];
        
        
        UILabel * ll5 = [UILabel new];
        [_view2 addSubview:ll5];
        ll5.text = @"1、妊娠或哺乳期妇女；\n2、过敏体质；\n3、使用部位有皮肤破损或皮肤病者；\n4、合并心肝肾或造血系统原发疾病者、精神疾病患者、内置心脏起搏器患者及体内植入其他金属医疗器械者。";
        ll5.textColor = RGBColor(102, 102, 102);
        ll5.font = ZYQFONT(15);
        [ll5 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(ll2);
            make.top.equalTo(ll4.mas_bottom).offset(5*IPADSCALE);
            make.right.equalTo(self.view.mas_right).offset(-40*IPADSCALE);
        }];
        ll5.numberOfLines = 0;
        
        UILabel * ll6 = [UILabel new];
        [_view2 addSubview:ll6];
        
        ll6.text = @"三、应急措施";
        ll6.textColor = RGBColor(50, 60, 71);
        ll6.font = ZYQFONT(17);
        [ll6 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.height.equalTo(ll2);
            make.top.equalTo(ll5.mas_bottom).offset(15*IPADSCALE);
            make.right.equalTo(self.view.mas_right).offset(-40*IPADSCALE);
        }];
        
        
        
        UILabel * ll7 = [UILabel new];
        [_view2 addSubview:ll7];
        ll7.text = @"1、遇设备出现非正常状态时，应立即停止使用，在确保安全的前提下联系厂家解决；\n2、发现设备工作时出现异常的声音、火光、烟雾等情况，应立即切断电源，使设备停止工作；\n3、设备出现故障时，应使用“故障停用”标识牌进行标识，并致电厂家保修（400-870-8885），如条件允许，可将故障设备移至特定区域放置。";
        ll7.textColor = RGBColor(102, 102, 102);
        ll7.font = ZYQFONT(15);
        [ll7 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(ll2);
            make.top.equalTo(ll6.mas_bottom).offset(5*IPADSCALE);
            make.right.equalTo(self.view.mas_right).offset(-40*IPADSCALE);
        }];
        ll7.numberOfLines = 0;
        
    }
    
    
    
    
}


@end
